<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>slot默认值</title>
    <script src="../lib/vue_v2.6.14.js"></script>
  </head>
  <body>
    <div id="app">
      <cpn-son>
        <a href="https://www.baidu.com" target="blank">百度</a>
      </cpn-son>
      <cpn-son></cpn-son>
      <cpn-son></cpn-son>
      <cpn-son>
        <p>我是p元素</p>
        <div>我是div元素</div>
      </cpn-son>
    </div>

    <template id="cpn">
      <div style="margin-bottom: 50px">
        <h2>我是子组件</h2>
        <p>我是内容，哈哈哈哈</p>
        <!-- 默认值：如果传入值就替换，未传入就使用默认值 -->
        <!-- 默认值是一个按钮 -->
        <slot><button>按钮</button></slot>
      </div>
    </template>
    <script>
      // 子组件
      Vue.component('cpn-son', {
        template: '#cpn'
      })

      // 父组件
      const vm = new Vue({
        el: '#app',
        data: {}
      })
    </script>
  </body>
</html>
